package thu.cs.segroup.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

public class TestCase implements Serializable {

	private String id;
	private String inputTypes;
	private String output;
	private String service_id;
	private String method;
	private String category;
	private HashMap<String, Object> props;
	private List<TestCaseConfig> configs;
		
	public TestCase() {
		super();
		props = new HashMap<String, Object>();
		configs = new ArrayList<TestCaseConfig>();
	}

	public TestCase(String id, String inputTypes, String output,
			String service_id, String method, String category) {
		super();
		this.id = id;
		this.inputTypes = inputTypes;
		this.output = output;
		this.service_id = service_id;
		this.method = method;
		this.category = category;
		props = new HashMap<String, Object>();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getInputTypes() {
		return inputTypes;
	}

	public void setInputTypes(String inputTypes) {
		this.inputTypes = inputTypes;
	}

	public String getOutput() {
		return output;
	}

	public void setOutput(String output) {
		this.output = output;
	}

	public String getService_id() {
		return service_id;
	}

	public void setService_id(String service_id) {
		this.service_id = service_id;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public void addConfig(TestCaseConfig _config) {
		configs.add(_config);
	}
	
	public List<TestCaseConfig> getConfigs() {
		return configs;
	}
	
	public void addProperty(String key, Object value) {
		props.put(key, value);
	}
	
	public Object getPropertyByKey(String key) {
		return props.get(key);
	}
	
	public HashMap<String, Object> getProps() {
		return props;
	}

	public List<TestTask> getTaskList() {
		ArrayList<TestTask> task_list = new ArrayList<TestTask>();
		for (int i = 0; i < configs.size(); i++) {
			TestTask task = new TestTask();
			task.setCategory(this.category);
			task.setWsdlURL(this.service_id);
			task.setInputTypes(this.inputTypes);
			task.setMethodName(this.method);
			task.setOutputTypes(this.output);
			task.setThreadCount(configs.get(i).getThreadCount());
			task.addAllProp(this.props);
			task_list.add(task);
		}
		return task_list;
	}
	
}


